package kr.co.skplanet.commute.dto;

public class CalDTO {
	private int value1;
	private String op;
	private int value2;
	private String result;
	
	public int getValue1() {
		return value1;
	}
	public void setValue1(int value1) {
		this.value1 = value1;
	}
	public String getOp() {
		return op;
	}
	public void setOp(String op) {
		this.op = op;
	}
	public int getValue2() {
		return value2;
	}
	public void setValue2(int value2) {
		this.value2 = value2;
	}
	public String getResult() {
		return result;
	}
	public void setResult() {
		result = value1 + " " + op + " " + value2;

		try {
			if (op.equals("+")) {
				result = result + " = " + (value1 + value2);
			} else if (op.equals("-")) {
				result = result + " = " + (value1 - value2);
			} else if (op.equals("*")) {
				result = result + " = " + (value1 * value2);
			} else if (op.equals("/")) {
				int toException = value1 / value2;
				result = result + " = " + ((double)value1 / (double)value2);
			}
		} catch (ArithmeticException ex) {
			result = "0으로 나눌 수 없습니다.";
		}
	}
	
}
